package team.headnurse.nursemanagement.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.headnurse.nursemanagement.dao.PersonInformationDao;
import team.headnurse.nursemanagement.model.PersonInformation;
import team.headnurse.nursemanagement.service.PersonInformationService;

import javax.annotation.Resource;

/**
 * @author Eugene-Forest
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class PersonInformationServiceImpl implements PersonInformationService {

    @Resource
    private PersonInformationDao personInformationDao;

    /**
     * 插入一条个人信息记录
     *
     * @param information 个人信息对象
     * @return 如果成功则返回数字1
     */
    @Override
    public int insert(PersonInformation information) {
        return personInformationDao.insert(information);
    }

    /**
     * 通过id删除一条个人信息记录
     *
     * @param staffId 员工id
     * @return 如果成功则返回数字1
     */
    @Override
    public int deleteById(String staffId) {
        return personInformationDao.deleteById(staffId);
    }

    /**
     * 更新一条个人信息记录
     *
     * @param information 个人信息对象
     * @return 如果成功则返回数字1
     */
    @Override
    public int update(PersonInformation information) {
        return personInformationDao.update(information);
    }

    /**
     * 通过id查找一条个人信息记录
     *
     * @param staffId 员工id
     * @return 如果成功则返回一个个人信息对象
     */
    @Override
    public PersonInformation selectById(String staffId) {
        return personInformationDao.selectById(staffId);
    }
}
